package com.Txunda.fxw.ui.activity.other;

import java.util.Map;

import com.Txunda.fxw.BuildConfig;
import com.Txunda.fxw.R;
import com.Txunda.fxw.base.utils.tool.Toolkit;
import com.Txunda.fxw.base.utils.util.JSONUtils;
import com.Txunda.fxw.ui.base.BaseAty;
import com.Txunda.fxw.ui.http.AboutUs;
import com.Txunda.fxw.ui.toolkit.glide.GlideUtils;
import com.bumptech.glide.Glide;
import com.lidroid.xutils.view.annotation.ViewInject;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 关于我们
 *
 * @author Administrator
 */
public class AboutUsAty extends BaseAty {

    @ViewInject(R.id.aty_title3_tv_center)
    private TextView aty_title3_tv_center;
    private AboutUs aboutUs;
    @ViewInject(R.id.app_logo)
    private ImageView app_logo;
    @ViewInject(R.id.app_name)
    private TextView app_name;
    @ViewInject(R.id.tv_company)
    private TextView tv_company;
    @ViewInject(R.id.tv_up)
    private TextView tv_up;
    @ViewInject(R.id.app_versions)
    private TextView app_versions;//版本号
    @ViewInject(R.id.aptitude_iv)
    private ImageView aptitude_iv;

    private int w = 0;
    private int h = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        showProgressDialog();
        aboutUs.aboutUs(this);

        GlideUtils.urlCenterCrop("http://www.yiyuanchazuo.com/WechatIMG1063.jpeg", w, h, aptitude_iv);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.aty_about_us_aty;
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void initialized() {
        aty_title3_tv_center.setText("公司资质");
        aboutUs = new AboutUs();
        app_versions.setText("版本:" + BuildConfig.VERSION_NAME);//
        w = Toolkit.dip2px(this, 180);
        h = Toolkit.dip2px(this, 240);
    }

    @Override
    public void onComplete(String requestUrl, String jsonStr) {
        super.onComplete(requestUrl, jsonStr);
        if (requestUrl.contains("aboutUs")) {
            Map<String, String> map = JSONUtils.parseKeyAndValueToMap(jsonStr);
            if ("success".equals(map.get("flag"))) {
                Map<String, String> data = JSONUtils.parseKeyAndValueToMap(map.get("data"));
                Glide.with(this).load(data.get("com_logo")).into(app_logo);
                app_name.setText(data.get("app_name"));
                tv_company.setText(data.get("company"));
                tv_up.setText(data.get("copy_title"));
            }
        }
    }

    @Override
    protected void requestData() {

    }


}
